package com.winit.service.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.winit.core.service.ServiceB;

@RestController
public class TestController {

    @Reference(check = true, version = "${serviceB.service.version}")
    private ServiceB serviceB;

    @RequestMapping("/{name}")
    @HystrixCommand(fallbackMethod = "defaultHello", commandProperties = { @HystrixProperty(name = "execution.isolation.strategy", value = "SEMAPHORE") })
    public String test(@PathVariable("name") String name) {
        return serviceB.sayHallo(name);
    }

    public String defaultHello(String name) {
        return "default hello from A " + name;
    }
}
